package com.jt.controller;

import com.jt.mapper.UserMapper;
import com.jt.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


@Controller
public class UserController {
    @Autowired
    private UserMapper userMapper;
    @RequestMapping("/doFind")
    public String find(Model model){
        List<User> userList=userMapper.selectList(null);
        model.addAttribute("userList", userList);
        return "userList";
    }
    @RequestMapping("/doAjax")
    public String findAjax(){

        return "userAjax";
    }


    @RequestMapping("/userAjax")
    @ResponseBody
    public List<User> userAjax(){
        return userMapper.selectList(null);
    }

    //    以下练习内容
    @RequestMapping("/doAjax_Pra")
    public String findAjax_Pra(){

        return "userAjax_Pra";
    }
    @RequestMapping("/userAjax_Pra")
    @ResponseBody
    public List<User> userAjax_Pra(){
        return userMapper.selectList(null);
    }
}
